package initialize

import (
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
	_ "user_api/docs"
	"user_api/middlewares"
	"user_api/routers"
)

func Routers() *gin.Engine {
	Routers := gin.Default()

	//配置跨域
	Routers.Use(middlewares.Cors())

	Routers.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

	ApiLoginGroup := Routers.Group("/v1/login")

	routers.InitBaseRouter(ApiLoginGroup)

	ApiUserGroup := Routers.Group("/v1/user")
	routers.InitUserRouter(ApiUserGroup)

	ApiRoleGroup := Routers.Group("/v1/role")
	routers.InitRoleRouter(ApiRoleGroup)
	return Routers
}
